﻿using UnityEngine;

namespace MrPP.SerriedCabinet
{
    [ExecuteInEditMode]
    public class UILocked : MonoBehaviour
    {

        [SerializeField]
        private Transform _target;

        [SerializeField]
        private Vector3 _original;


        [SerializeField]
        private RectTransform _rect;

        // Update is called once per frame
        void Update()
        {
            if (this.transform.hasChanged)
            {
                Vector3 now = _target.lossyScale;
                var rect = _rect.rect;
                _rect.sizeDelta = new Vector2(500f / (_original.z/ now.z), 500f / (_original.y / now.y));
            }
        }
    }
}